def LCPstr(s1, s2):
    len1 = len(s1)
    len2 = len(s2)
    dp = [[0] * (len1 + 1)] * (len2 + 1)
    result = 0
    index = 0
    for i in range(1, len2 + 1):
        for j in range(1, len1 + 1):
            if s2[i - 1] == s1[j - 1]:
                dp[i][j] = dp[i - 1][j - 1] + 1

                if dp[i][j] > result:
                    index = i

                result = max(dp[i][j], result)
    common_str = s2[index - result:index]
    return common_str

if __name__=="__main__":
    a = 'hellooxworld'
    b = "aalooxoxp"
    print(LCPstr(a, b))
